﻿<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %> 
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="DailyReportUserControl.ascx.cs" Inherits="CSSoft.VNTower.DailyReport.DailyReportUserControl" %>
<%@ Register Assembly="Telerik.Web.UI, Version=2011.1.322.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4"
    Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<style type="text/css">
    .HeaderLable {
        background-color: #000080; 
        color: #FFFFFF; 
    }
    .FieldLable{background-color: #CCFFCC;}
    .Center{text-align: center;}
    .Right{text-align: right;}
    .Top{vertical-align: top;}
    .PageWidth{width: 900px;}
    .UploadButton{ position:relative; top:-22px; left:200px; }
</style>
<h1 class="PageWidth HeaderLable Center"> BÁO CÁO HÀNG NGÀY (DAILY REPORT)</h1>
<table class="PageWidth">
<tr>
<td class="FieldLable">Họ tên/Name</td>
<td>
    <telerik:RadTextBox ID="Name" Runat="server" Skin="Windows7" Width="98%" 
            ReadOnly="True">
    </telerik:RadTextBox>
    </td>
<td rowspan="2" class="FieldLable Center" width="60px">
    TO</td>
<td rowspan="2" width="486px">
    <SharePoint:PeopleEditor ID="EmailTo" runat="server"
        AllowEmpty="true" MultiSelect="true" AllowTypeIn="true"  
        PlaceButtonsUnderEntityEditor="false" SelectionSet="User" BorderColor="#B8CBDE" BorderStyle="Solid" BorderWidth="1px" Width="98%" Height="100%" />
 </td>
</tr>
<tr>
<td class="FieldLable">Mã NV/Code</td>
<td>
    <telerik:RadTextBox ID="Code" Runat="server" Skin="Windows7" Width="98%" 
            ReadOnly="True">
    </telerik:RadTextBox>
    </td>
</tr>
<tr>
<td class="FieldLable">Chức vụ/Title</td>
<td>
    <telerik:RadTextBox ID="Title" Runat="server" Skin="Windows7" Width="98%" 
            ReadOnly="True">
    </telerik:RadTextBox>
    </td>
<td rowspan="2" class="FieldLable Center">
    CC</td>
<td rowspan="2">    
    <SharePoint:PeopleEditor ID="EmailCC" runat="server"
        AllowEmpty="true" MultiSelect="true" AllowTypeIn="true"  BorderColor="#B8CBDE" BorderStyle="Solid" BorderWidth="1px"
        PlaceButtonsUnderEntityEditor="false" SelectionSet="User" Width="98%" Height="100%"/></td>
</tr>
<tr>
<td class="FieldLable">Phòng/Division</td>
<td>
    <telerik:RadTextBox ID="Division" Runat="server" Skin="Windows7" Width="98%" 
            ReadOnly="True">
    </telerik:RadTextBox>
    </td>
</tr>
<tr>
<td class="FieldLable">Vùng/Region</td>
<td>
    <telerik:RadTextBox ID="Region" Runat="server" Skin="Windows7" Width="98%" 
            ReadOnly="True">
    </telerik:RadTextBox>
    </td>
<td rowspan="2" class="FieldLable Center">
    Ghi chú /<br />
    Note</td>
<td rowspan="2">
    <telerik:RadTextBox ID="Note" Runat="server" Skin="Windows7" 
        TextMode="MultiLine" Width="98%" Height="48px">
    </telerik:RadTextBox>
    </td>
</tr>
<tr>
<td class="FieldLable">Ngày/Date</td>
<td>
        <telerik:RadDatePicker ID="ReportDate" runat="server" Culture="vi-VN" 
            Skin="Office2007" Width="100%" AutoPostBack="true" 
            onselecteddatechanged="ReportDate_SelectedDateChanged">
            <Calendar UseRowHeadersAsSelectors="False" UseColumnHeadersAsSelectors="False" 
                        ViewSelectorText="x" Skin="Office2007"></Calendar>

            <DateInput DisplayDateFormat="dd/MM/yyyy" DateFormat="dd/MM/yyyy" 
                AutoPostBack="True"></DateInput>

            <DatePopupButton ImageUrl="" HoverImageUrl=""></DatePopupButton>
        </telerik:RadDatePicker>
    </td>
</tr>
</table>
<p>
    <strong> THÊM TẬP TIN BÁO CÁO CÁC DỰ ÁN ĐANG LÀM<br />
ADD FILE TO REPORT WORKING PROJECTS</strong>
<table class="PageWidth">
<tr>
<td class="FieldLable" width="120px">Chọn dự án<br />
    Select project</td>
<td>
    <telerik:RadComboBox ID="Project" Runat="server" Skin="Office2007" DataValueField="Id" DataTextField="Title" Width="100%">
    </telerik:RadComboBox>
    </td>
</tr>
<tr>
<td class="FieldLable">Tải tập tin<br />
    Upload file</td>
<td style="margin-left: 80px">
    <telerik:RadUpload ID="ReportFiles" runat="server" Width="100%" OnClientAdded="ReportFiles_OnClientAddedHandler"></telerik:RadUpload>
    <telerik:RadButton ID="Upload" runat="server" Skin="Windows7" 
    Text="Upload" onclick="Upload_Click" CssClass="UploadButton" Width="90px">
</telerik:RadButton>
    </td>   
</tr>
</table>
</p>

<p>
    <strong> CÁC TẬP TIN ĐÃ BÁO CÁO TRONG NGÀY<br />
    THE FILES REPORTED IN DATE</strong>
</p>

<script type="text/javascript">
        <!--
    var hasChanges, editedRow;

    function FilesRowClick(sender, eventArgs) {
        if (editedRow && hasChanges) {
            hasChanges = false;
            if (confirm("Update changes?")) {

                $find("<%= Files.ClientID %>").get_masterTableView().updateItem(editedRow);
            }
        }
    }

    function FilesRowDblClick(sender, eventArgs) {
        editedRow = eventArgs.get_itemIndexHierarchical();
        $find("<%= Files.ClientID %>").get_masterTableView().editItem(editedRow);
    }

    function FilesGridCommand(sender, args) {
        if (args.get_commandName() != "Edit") {
            editedRow = null;
        }
    }
     -->    
    </script>
        <telerik:RadGrid ID="Files" runat="server" AutoGenerateColumns="False" 
            CellSpacing="0" GridLines="None" Skin="Windows7" CssClass="PageWidth" 
            OnNeedDataSource="Files_NeedDataSource" ShowGroupPanel="True" 
            OnDeleteCommand="Files_ItemDeleted" OnUpdateCommand="Files_UpdateCommand">
            <ClientSettings AllowDragToGroup="True">
<ClientEvents OnRowClick="FilesRowClick" OnRowDblClick="FilesRowDblClick" 
                    OnCommand="FilesGridCommand"></ClientEvents>
            </ClientSettings>
            <GroupPanel Text="Kéo một cột vào đây để nhóm theo cột đó &lt;br/&gt; Drag a column header and drop it here to group by that column">
            </GroupPanel>
<MasterTableView EditMode="InPlace">
<CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>

<RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>

<ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
    <GroupByExpressions>
        <telerik:GridGroupByExpression>
            <SelectFields>
                <telerik:GridGroupByField HeaderText="Dự án/Project" FieldName="Project"></telerik:GridGroupByField>
            </SelectFields>
            <GroupByFields>
                <telerik:GridGroupByField FieldName="Project"></telerik:GridGroupByField>
            </GroupByFields>
        </telerik:GridGroupByExpression>
    </GroupByExpressions>
    <Columns>
        <telerik:GridEditCommandColumn FilterControlAltText="Filter Edit command column">
        </telerik:GridEditCommandColumn>
        <telerik:GridBoundColumn DataField="Project" 
            FilterControlAltText="Filter Project column" HeaderText="Dự án&lt;br/&gt;Project" 
            UniqueName="Project" ReadOnly="true">            
        </telerik:GridBoundColumn>
        <telerik:GridTemplateColumn FilterControlAltText="Filter FileType column" 
            UniqueName="FileType" HeaderText="Tập tin&lt;br/&gt;File">
            <ItemTemplate>
                <a href='<%# Eval("FileUrl") %>'><img src='<%# Eval("FileType") %>' /> <%# Eval("FileCode") %></a>
            </ItemTemplate>
        </telerik:GridTemplateColumn>        
        <telerik:GridTemplateColumn FilterControlAltText="Filter FileName column" 
            UniqueName="FileName" HeaderText="Tên tập tin&lt;br/&gt;FileName">
            <ItemTemplate>
                <a href='<%# Eval("FileUrl") %>'><%# Eval("Title")%></a>
            </ItemTemplate>
            <EditItemTemplate>            
                <telerik:RadTextBox ID="Title" Runat="server" Skin="Windows7" Width="100%" 
                        Text='<%# Eval("Title")%>' ReadOnly='<%# Eval("NotIsReporter") %>'>
                </telerik:RadTextBox>
            </EditItemTemplate>
        </telerik:GridTemplateColumn>
        <telerik:GridTemplateColumn FilterControlAltText="Filter Note column" 
            UniqueName="Note"
            HeaderText="Ghi chú&lt;br/&gt;Note" >
            <ItemTemplate>
                <asp:Literal ID="Note" runat="server" Text='<%# Eval("Note") %>' />
            </ItemTemplate>
            <EditItemTemplate>
                <telerik:RadTextBox ID="Note" runat="server" Skin="Windows7" Width="100%" Text='<%# Eval("Note") %>' Enabled='<%# Eval("IsReporter") %>' />
            </EditItemTemplate>
        </telerik:GridTemplateColumn>
        <telerik:GridButtonColumn ConfirmText="Delete this file?" ConfirmDialogType="RadWindow"
            ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" ConfirmDialogHeight="100px"
            ConfirmDialogWidth="220px" HeaderText="Xóa?&lt;br/&gt;Delete?"/>
        <telerik:GridBoundColumn DataField="Id" 
            FilterControlAltText="Filter Id column" HeaderText="_Id" 
            UniqueName="Id" Visible="False">
        </telerik:GridBoundColumn>
        <telerik:GridTemplateColumn FilterControlAltText="Filter PMAproved column" 
            UniqueName="PMAproved">
            <ItemTemplate>
                <asp:CheckBox ID="PMAproved" runat="server" Checked='<%# Eval("PMAprovedCheckBox") %>' Enabled="false" />
            </ItemTemplate>
            <EditItemTemplate>
                <asp:CheckBox ID="PMAproved" runat="server" Checked='<%# Eval("PMAprovedCheckBox") %>' Enabled='<%# Eval("NotIsProjectManager") %>' />
            </EditItemTemplate>
        </telerik:GridTemplateColumn>
        <telerik:GridTemplateColumn FilterControlAltText="Filter PMComment column" 
            UniqueName="PMComment"
            HeaderText="Ý KIẾN CỦA CHỦ NHIỆM DA/NGƯỜI QUẢN LÝ&lt;br/&gt;PM/DIRECT MANAGER's JUDGERMENT" >
            <ItemTemplate>
                <asp:Literal ID="PMComment" runat="server" Text='<%# Eval("PMComment") %>' />
            </ItemTemplate>
            <EditItemTemplate>
                <telerik:RadTextBox ID="PMComment" runat="server" Skin="Windows7" Width="100%" Text='<%# Eval("PMComment") %>' Enabled='<%# Eval("NotIsProjectManager") %>' />
            </EditItemTemplate>
        </telerik:GridTemplateColumn>
    </Columns>

<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
</EditFormSettings>
</MasterTableView>

<ClientSettings AllowDragToGroup="True">
    <ClientEvents OnRowClick="FilesRowClick" OnRowDblClick="FilesRowDblClick"
        OnCommand="FilesGridCommand" />
</ClientSettings>

<FilterMenu EnableImageSprites="False"></FilterMenu>

<HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"></HeaderContextMenu>
        </telerik:RadGrid>
<p>
<table class="PageWidth Center">
<tr>
<td>
<telerik:RadButton ID="Submit" runat="server" Skin="Windows7" Text="Submit" onclick="Submit_Click" Width="90px"></telerik:RadButton>
    <asp:Literal ID="SubmitMessage" runat="server"></asp:Literal>
</td>
</tr>
<tr>
<td>
    <hr /></td>
</tr>
</table>
</p>
<script type="text/javascript">
        <!--
    var hasChangesFiles, editedRowFiles;

    function FilesRowClick(sender, eventArgs) {
        if (editedRowFiles && hasChangesFiles) {
            hasChangesFiles = false;
            if (confirm("Update changes?")) {

                $find("<%= Files.ClientID %>").get_masterTableView().updateItem(editedRowFiles);
            }
        }
    }

    function FilesRowDblClick(sender, eventArgs) {
        editedRowFiles = eventArgs.get_itemIndexHierarchical();
        $find("<%= Files.ClientID %>").get_masterTableView().editItem(editedRowFiles);
    }

    function FilesGridCommand(sender, args) {
        if (args.get_commandName() != "Edit") {
            editedRowFiles = null;
        }
    }
     -->    
    </script>
<table class="PageWidth">
<tr>
<td class="FieldLable" style="width:246px">Ý KIẾN CỦA Q.L.BỘ PHẬN<br />
    LINE MANAGER COMMENT</td>
<td class="Center" colspan="2">
    <telerik:RadTextBox ID="LineManagerComment" Runat="server" Skin="Windows7" Enabled="false" 
        TextMode="MultiLine" Width="98%" Height="60px">
    </telerik:RadTextBox>
    </td>
</tr>
<tr>
<td class="FieldLable" style="width:246px">REPORT STATUS</td>
<td>
    <asp:Literal ID="Status" runat="server"></asp:Literal>
    </td>
<td>
    <telerik:RadButton ID="Approved" runat="server" Skin="Windows7" Visible="false"
    Text="Approved" onclick="Approved_Click"></telerik:RadButton>
    <telerik:RadButton ID="Rejected" runat="server" Skin="Windows7" Visible="false" 
    Text="Rejected" onclick="Rejected_Click"></telerik:RadButton>
    <asp:Literal ID="ActionMessage" runat="server"></asp:Literal>
</td>
</tr>
</table>
</p>

<script type="text/javascript">
    function ReportFiles_OnClientAddedHandler(radUpload, args) {
        var curLiEl = args.get_row();

        var inputDesc = CreateInput("Comment", "text");
        inputDesc.className = "TextField";
        inputDesc.id = inputDesc.name = radUpload.getID(inputDesc.name);
        var labelDesc = CreateLabel("Ghi chú/Comment", inputDesc.id);

        //Add a File label in front of the file input
        var fileInputSpan = curLiEl.getElementsByTagName("span")[0];
        var checkboxSelect = curLiEl.childNodes[0];
        var buttonRemove = curLiEl.childNodes[2];
        var labelFile = CreateLabel("Tập tin/File", radUpload.getID());

        curLiEl.insertBefore(labelFile, checkboxSelect);
        curLiEl.insertBefore(labelDesc, buttonRemove);
        curLiEl.insertBefore(inputDesc, buttonRemove);
    }

    function CreateLabel(text, associatedControlId) {
        var label = document.createElement("label");
        label.innerHTML = text;
        label.setAttribute("for", associatedControlId);
        label.style.fontSize = 12;

        return label;
    }

    function CreateInput(inputName, type) {
        var input = document.createElement("input");
        input.type = type;
        input.name = inputName;

        return input;
    }
</script>